<?php

namespace App\Http\Controllers;

use App\Models\Device;
use Illuminate\Http\Request;

class ToolController extends Controller
{
  public function deviceRemoveDuplicate()
  {
    $devices = Device::all();
    $rs = $devices->each(function ($device) {
      $device->imei = substr($device->imei, 0, 32);
    });
    $unique = $rs->unique('imei');
    Device::truncate();
    Device::insert($unique->values()->toArray());
    return $this->success(0, '');
  }
}
